Big window fix for Win32. Big windows are still emulated within 16-bit
authorIvan, Wong Yat Cheung <email@ivanwong.info>
Fri, 11 Mar 2005 23:50:21 +0000 (23:50 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Fri, 11 Mar 2005 23:50:21 +0000 (23:50 +0000)
2005-03-12  Ivan, Wong Yat Cheung  <email@ivanwong.info>

Big window fix for Win32. Big windows are still emulated within
16-bit coordinate limits, though. Big windows now work on NT-based
Windows. (#169989)

* gdk/win32/gdkgc-win32.c (_gdk_win32_gdkregion_to_hrgn): Use
32-bit coordinates.

* gdk/win32/gdkgeometry-win32.c: Largely rewrite.

* gdk/win32/gdkwindow-win32.c: Minor related changes.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gdk/win32/gdkgc-win32.c
gdk/win32/gdkgeometry-win32.c
gdk/win32/gdkwindow-win32.c

index 0de90140b723c86faf3995b68b4ec70192583dcb..d685903d90fa05aa1ee82ff255b96ed8b319b809 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-03-12  Ivan, Wong Yat Cheung  <email@ivanwong.info>
+
+       Big window fix for Win32. Big windows are still emulated within
+       16-bit coordinate limits, though. Big windows now work on NT-based
+       Windows. (#169989)
+
+       * gdk/win32/gdkgc-win32.c (_gdk_win32_gdkregion_to_hrgn): Use
+       32-bit coordinates.
+
+       * gdk/win32/gdkgeometry-win32.c: Largely rewrite.
+
+       * gdk/win32/gdkwindow-win32.c: Minor related changes.
+       
 2005-03-10  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkliststore.c (gtk_list_store_insert_with_valuesv): 
index 0de90140b723c86faf3995b68b4ec70192583dcb..d685903d90fa05aa1ee82ff255b96ed8b319b809 100644 (file)
@@ -1,3 +1,16 @@
+2005-03-12  Ivan, Wong Yat Cheung  <email@ivanwong.info>
+
+       Big window fix for Win32. Big windows are still emulated within
+       16-bit coordinate limits, though. Big windows now work on NT-based
+       Windows. (#169989)
+
+       * gdk/win32/gdkgc-win32.c (_gdk_win32_gdkregion_to_hrgn): Use
+       32-bit coordinates.
+
+       * gdk/win32/gdkgeometry-win32.c: Largely rewrite.
+
+       * gdk/win32/gdkwindow-win32.c: Minor related changes.
+       
 2005-03-10  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkliststore.c (gtk_list_store_insert_with_valuesv): 
index 0de90140b723c86faf3995b68b4ec70192583dcb..d685903d90fa05aa1ee82ff255b96ed8b319b809 100644 (file)
@@ -1,3 +1,16 @@
+2005-03-12  Ivan, Wong Yat Cheung  <email@ivanwong.info>
+
+       Big window fix for Win32. Big windows are still emulated within
+       16-bit coordinate limits, though. Big windows now work on NT-based
+       Windows. (#169989)
+
+       * gdk/win32/gdkgc-win32.c (_gdk_win32_gdkregion_to_hrgn): Use
+       32-bit coordinates.
+
+       * gdk/win32/gdkgeometry-win32.c: Largely rewrite.
+
+       * gdk/win32/gdkwindow-win32.c: Minor related changes.
+       
 2005-03-10  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkliststore.c (gtk_list_store_insert_with_valuesv): 
index 1c58ba34f44d783b009e1c5244cb8ae9539331e8..3b520417ce4b5f31487ec938059fe15a24764a28 100644 (file)
@@ -1252,20 +1252,16 @@ _gdk_win32_gdkregion_to_hrgn (GdkRegion *region,
   rgndata->rdh.iType = RDH_RECTANGLES;
   rgndata->rdh.nCount = rgndata->rdh.nRgnSize = 0;
   SetRect (&rgndata->rdh.rcBound,
-          G_MAXSHORT, G_MAXSHORT, G_MINSHORT, G_MINSHORT);
+          G_MAXLONG, G_MAXLONG, G_MINLONG, G_MINLONG);
 
   for (i = 0; i < region->numRects; i++)
     {
       rect = ((RECT *) rgndata->Buffer) + rgndata->rdh.nCount++;
 
-      rect->left = CLAMP (boxes[i].x1 + x_origin,
-                         G_MINSHORT, G_MAXSHORT);
-      rect->right = CLAMP (boxes[i].x2 + x_origin,
-                          G_MINSHORT, G_MAXSHORT);
-      rect->top = CLAMP (boxes[i].y1 + y_origin,
-                        G_MINSHORT, G_MAXSHORT);
-      rect->bottom = CLAMP (boxes[i].y2 + y_origin,
-                           G_MINSHORT, G_MAXSHORT);
+      rect->left = boxes[i].x1 + x_origin;
+      rect->right = boxes[i].x2 + x_origin;
+      rect->top = boxes[i].y1 + y_origin;
+      rect->bottom = boxes[i].y2 + y_origin;
 
       if (rect->left < rgndata->rdh.rcBound.left)
        rgndata->rdh.rcBound.left = rect->left;
index 66a03b0f7e6fa245c0706dd18595c052dcb070c5..ea36ac9a149f7a5e6cc42b969805167b361e8675 100644 (file)
  */
 
 /* gdkgeometry-win32.c: emulation of 32 bit coordinates within the
- * limits of Win32 GDI. Just a copy of the X11 version, more or less.
- * Probably totally bogus in functionality. Just a quick hack, to
- * get the thing to build. Need to write some test code for it.
- * Well, need to find out what it is supposed to do first ;-)
+ * limits of Win32 GDI. The idea of big window emulation is more or less
+ * a copy of the X11 version, and the equvalent of guffaw scrolling
+ * is ScrollWindowEx(). While we determine the invalidated region
+ * ourself during scrolling, we do not pass SW_INVALIDATE to
+ * ScrollWindowEx() to avoid a unnecessary WM_PAINT.
  *
+ * Bits are always scrolled correctly by ScrollWindowEx(), but
+ * some big children may hit the coordinate boundary (i.e.
+ * win32_x/win32_y < -16383) after scrolling. They needed to be moved
+ * back to the real position determined by gdk_window_compute_position().
+ * This is handled in gdk_window_postmove().
+ * 
  * The X11 version by Owen Taylor <otaylor@redhat.com>
  * Copyright Red Hat, Inc. 2000
  * Win32 hack by Tor Lillqvist <tml@iki.fi>
  * and Hans Breuer <hans@breuer.org>
+ * Modified by Ivan, Wong Yat Cheung <email@ivanwong.info>
+ * so that big window emulation finally works.
  */
 
 #include <config.h>
 #include "gdkregion-generic.h"
 #include "gdkprivate-win32.h"
 
-#define SIZE_LIMIT 32000
+#define SIZE_LIMIT 32767
 
-typedef struct _GdkWindowQueueItem GdkWindowQueueItem;
 typedef struct _GdkWindowParentPos GdkWindowParentPos;
 
-#if 0
-
-typedef enum {
-  GDK_WINDOW_QUEUE_TRANSLATE,
-  GDK_WINDOW_QUEUE_ANTIEXPOSE
-} GdkWindowQueueType;
-
-struct _GdkWindowQueueItem
-{
-  GdkWindow *window;
-  gulong serial;
-  GdkWindowQueueType type;
-  union {
-    struct {
-      gint dx;
-      gint dy;
-    } translate;
-    struct {
-      GdkRegion *area;
-    } antiexpose;
-  } u;
-};
-
-#endif
-
 struct _GdkWindowParentPos
 {
   gint x;
@@ -80,22 +63,16 @@ static void gdk_window_compute_position   (GdkWindowImplWin32     *window,
 static void gdk_window_compute_parent_pos (GdkWindowImplWin32     *window,
                                           GdkWindowParentPos     *parent_pos);
 
-static void gdk_window_premove            (GdkWindow          *window,
-                                          GdkWindowParentPos *parent_pos);
 static void gdk_window_postmove           (GdkWindow          *window,
-                                          GdkWindowParentPos *parent_pos);
-static void gdk_window_queue_translation  (GdkWindow          *window,
-                                          gint                dx,
-                                          gint                dy);
+                                          GdkWindowParentPos *parent_pos,
+                                          gboolean           anti_scroll);
 static void gdk_window_tmp_unset_bg       (GdkWindow          *window);
 static void gdk_window_tmp_reset_bg       (GdkWindow          *window);
-static void gdk_window_clip_changed       (GdkWindow          *window,
+static GdkRegion *gdk_window_clip_changed (GdkWindow          *window,
                                           GdkRectangle       *old_clip,
                                           GdkRectangle       *new_clip);
-
-#if 0
-static GSList *translate_queue = NULL;
-#endif
+static void gdk_window_post_scroll        (GdkWindow          *window,
+                                          GdkRegion          *new_clip_region);
 
 void
 _gdk_windowing_window_get_offsets (GdkWindow *window,
@@ -123,219 +100,17 @@ _gdk_window_init_position (GdkWindow *window)
   gdk_window_compute_position (impl, &parent_pos, &impl->position_info);
 }
 
-static void
-gdk_window_copy_area_scroll (GdkWindow    *window,
-                            GdkRectangle *dest_rect,
-                            gint          dx,
-                            gint          dy)
-{
-#if 0
-  GdkWindowObject *obj = GDK_WINDOW_OBJECT (window);
-  GList *tmp_list;
-#endif
-
-  GDK_NOTE (MISC, g_print ("gdk_window_copy_area_scroll: %p %s %d,%d\n",
-                          GDK_WINDOW_HWND (window),
-                          _gdk_win32_gdkrectangle_to_string (dest_rect),
-                          dx, dy));
-
-  if (dest_rect->width > 0 && dest_rect->height > 0)
-    {
-      RECT clipRect;
-#ifdef G_ENABLE_DEBUG
-      RECT update_rect;
-#endif
-
-      clipRect.left   = dest_rect->x;
-      clipRect.top    = dest_rect->y;
-      clipRect.right  = clipRect.left + dest_rect->width;
-      clipRect.bottom = clipRect.top + dest_rect->height;
-
-      if (dx < 0)
-       clipRect.right -= dx;
-      else
-       clipRect.left -= dx;
-      if (dy < 0)
-       clipRect.bottom -= dy;
-      else
-       clipRect.top -= dy;
-
-      gdk_window_queue_translation (window, dx, dy);
-
-      if (!ScrollWindowEx (GDK_WINDOW_HWND (window),
-                           dx, dy, /* in: scroll offsets */
-                           NULL, /* in: scroll rect, NULL == entire client area */
-                           &clipRect, /* in: restrict to */
-                           NULL, /* in: update region */
-                           NULL, /* out: update rect */
-                           SW_INVALIDATE | SW_SCROLLCHILDREN))
-        WIN32_API_FAILED ("ScrollWindowEx");
-
-      GDK_NOTE (EVENTS,
-               (GetUpdateRect (GDK_WINDOW_HWND (window), &update_rect, FALSE),
-                g_print ("gdk_window_copy_area_scroll: post-scroll update rect: %s\n",
-                         _gdk_win32_rect_to_string (&update_rect))));
-    }
-
-#if 0 /* Not needed, ScrollWindowEx also scrolls the children. */
-  tmp_list = obj->children;
-  while (tmp_list)
-    {
-      GdkWindow *child = GDK_WINDOW (tmp_list->data);
-      GdkWindowObject *child_obj = GDK_WINDOW_OBJECT (child);
-         
-      gdk_window_move (child, child_obj->x + dx, child_obj->y + dy);
-      
-      tmp_list = tmp_list->next;
-    }
-#endif
-}
-
-static void
-compute_intermediate_position (GdkWin32PositionInfo *position_info,
-                              GdkWin32PositionInfo *new_info,
-                              gint                  d_xoffset,
-                              gint                  d_yoffset,
-                              GdkRectangle         *new_position)
-{
-  gint new_x0, new_x1, new_y0, new_y1;
-  
-  /* Wrap d_xoffset, d_yoffset into [-32768,32767] range. For the
-   * purposes of subwindow movement, it doesn't matter if we are
-   * off by a factor of 65536, and if we don't do this range
-   * reduction, we'll end up with invalid widths.
-   */
-  d_xoffset = (gint16)d_xoffset;
-  d_yoffset = (gint16)d_yoffset;
-  
-  if (d_xoffset < 0)
-    {
-      new_x0 = position_info->x + d_xoffset;
-      new_x1 = position_info->x + position_info->width;
-    }
-  else
-    {
-      new_x0 = position_info->x;
-      new_x1 = position_info->x + new_info->width + d_xoffset;
-    }
-
-  new_position->x = new_x0;
-  new_position->width = new_x1 - new_x0;
-  
-  if (d_yoffset < 0)
-    {
-      new_y0 = position_info->y + d_yoffset;
-      new_y1 = position_info->y + position_info->height;
-    }
-  else
-    {
-      new_y0 = position_info->y;
-      new_y1 = position_info->y + new_info->height + d_yoffset;
-    }
-  
-  new_position->y = new_y0;
-  new_position->height = new_y1 - new_y0;
-}
-
-#if 0
-
-static void
-gdk_window_guffaw_scroll (GdkWindow    *window,
-                         gint          dx,
-                         gint          dy)
-{
-  GdkWindowObject *obj = GDK_WINDOW_OBJECT (window);
-  GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
-
-  gint d_xoffset = -dx;
-  gint d_yoffset = -dy;
-  GdkRectangle new_position;
-  GdkWin32PositionInfo new_info;
-  GdkWindowParentPos parent_pos;
-  GList *tmp_list;
-  
-  GDK_NOTE (EVENTS, g_print ("gdk_window_guffaw_scroll: %p %d,%d\n",
-                            GDK_WINDOW_HWND (window), dx, dy));
-
-  gdk_window_compute_parent_pos (impl, &parent_pos);
-  gdk_window_compute_position (impl, &parent_pos, &new_info);
-
-  parent_pos.x += obj->x;
-  parent_pos.y += obj->y;
-  parent_pos.win32_x += new_info.x;
-  parent_pos.win32_y += new_info.y;
-  parent_pos.clip_rect = new_info.clip_rect;
-
-  gdk_window_tmp_unset_bg (window);
-
-  if (d_xoffset < 0 || d_yoffset < 0)
-    gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0));
-       
-  gdk_window_set_static_gravities (window, TRUE);
-
-  compute_intermediate_position (&impl->position_info, &new_info, d_xoffset, d_yoffset,
-                                &new_position);
-  
-  /* XXX: this is only translating the X11 code. Don't know why the
-   *  window movement needs to be done in three steps there, and here ??
-   */
-  if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                     new_position.x, new_position.y,
-                    new_position.width, new_position.height,
-                     SWP_NOACTIVATE | SWP_NOZORDER))
-    WIN32_API_FAILED ("SetWindowPos");
-  
-  tmp_list = obj->children;
-  while (tmp_list)
-    {
-      GDK_WINDOW_OBJECT(tmp_list->data)->x -= d_xoffset;
-      GDK_WINDOW_OBJECT(tmp_list->data)->y -= d_yoffset;
-
-      gdk_window_premove (tmp_list->data, &parent_pos);
-      tmp_list = tmp_list->next;
-    }
-  
-  if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                     new_position.x - d_xoffset, new_position.y - d_yoffset, 1, 1,
-                     SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE))
-    WIN32_API_FAILED ("SetWindowPos");
-
-  if (d_xoffset > 0 || d_yoffset > 0)
-    gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
-  
-  if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                     impl->position_info.x, impl->position_info.y,
-                     impl->position_info.width, impl->position_info.height,
-                     SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE))
-    WIN32_API_FAILED ("SetWindowPos");
-  
-  if (impl->position_info.no_bg)
-    gdk_window_tmp_reset_bg (window);
-  
-  impl->position_info = new_info;
-  
-  tmp_list = obj->children;
-  while (tmp_list)
-    {
-      gdk_window_postmove (tmp_list->data, &parent_pos);
-      tmp_list = tmp_list->next;
-    }
-}
-
-#endif
-
 void
 gdk_window_scroll (GdkWindow *window,
                   gint       dx,
                   gint       dy)
 {
-#if 0
-  gboolean can_guffaw_scroll = FALSE;
-#endif
   GdkRegion *invalidate_region;
   GdkWindowImplWin32 *impl;
   GdkWindowObject *obj;
   GdkRectangle dest_rect;
+  GList *tmp_list;
+  GdkWindowParentPos parent_pos;
   
   g_return_if_fail (GDK_IS_WINDOW (window));
 
@@ -371,27 +146,33 @@ gdk_window_scroll (GdkWindow *window,
       gdk_region_destroy (tmp_region);
     }
   
-  gdk_window_invalidate_region (window, invalidate_region, TRUE);
-  gdk_region_destroy (invalidate_region);
-#if 0
-  /* We can guffaw scroll if we are a child window, and the parent
-   * does not extend beyond our edges. Otherwise, we use XCopyArea, then
-   * move any children later
-   */
-  if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
+  gdk_window_compute_parent_pos (impl, &parent_pos);
+
+  parent_pos.x += obj->x;
+  parent_pos.y += obj->y;
+  parent_pos.win32_x += impl->position_info.x;
+  parent_pos.win32_y += impl->position_info.y;
+  parent_pos.clip_rect = impl->position_info.clip_rect;
+
+  gdk_window_tmp_unset_bg (window);
+
+  if (!ScrollWindowEx (GDK_WINDOW_HWND (window),
+                      dx, dy, NULL, NULL,
+                      NULL, NULL, SW_SCROLLCHILDREN))
+    WIN32_API_FAILED ("ScrollWindowEx");
+
+  if (impl->position_info.no_bg)
+    gdk_window_tmp_reset_bg (window);
+  
+  tmp_list = obj->children;
+  while (tmp_list)
     {
-      GdkWindowImplWin32 *parent_impl = GDK_WINDOW_IMPL_WIN32 (obj->parent->impl);  
-      can_guffaw_scroll = ((dx == 0 || (obj->x <= 0 && obj->x + impl->width >= parent_impl->width)) &&
-                          (dy == 0 || (obj->y <= 0 && obj->y + impl->height >= parent_impl->height)));
+      gdk_window_postmove (tmp_list->data, &parent_pos, FALSE);
+      tmp_list = tmp_list->next;
     }
 
-  if (!obj->children || !can_guffaw_scroll)
-    gdk_window_copy_area_scroll (window, &dest_rect, dx, dy);
-  else
-    gdk_window_guffaw_scroll (window, dx, dy);
-#else
-  gdk_window_copy_area_scroll (window, &dest_rect, dx, dy);
-#endif
+  gdk_window_invalidate_region (window, invalidate_region, TRUE);
+  gdk_region_destroy (invalidate_region);
 }
 
 void
@@ -410,6 +191,7 @@ _gdk_window_move_resize_child (GdkWindow *window,
   gint dx, dy;
   gboolean is_move;
   gboolean is_resize;
+  GdkRegion *new_clip_region;
   
   g_return_if_fail (window != NULL);
   g_return_if_fail (GDK_IS_WINDOW (window));
@@ -444,7 +226,8 @@ _gdk_window_move_resize_child (GdkWindow *window,
   gdk_window_compute_parent_pos (impl, &parent_pos);
   gdk_window_compute_position (impl, &parent_pos, &new_info);
 
-  gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
+  new_clip_region =
+    gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
 
   parent_pos.x += obj->x;
   parent_pos.y += obj->y;
@@ -457,55 +240,32 @@ _gdk_window_move_resize_child (GdkWindow *window,
   
   if (d_xoffset != 0 || d_yoffset != 0)
     {
-      GdkRectangle new_position;
-
       GDK_NOTE (MISC, g_print ("...d_xoffset=%d d_yoffset=%d\n", d_xoffset, d_yoffset));
 
-      gdk_window_set_static_gravities (window, TRUE);
-
-      if (d_xoffset < 0 || d_yoffset < 0)
-       gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0));
-
-      compute_intermediate_position (&impl->position_info, &new_info, d_xoffset, d_yoffset,
-                                    &new_position);
-      
-      GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%s)\n",
-                              GDK_WINDOW_HWND (window),
-                              _gdk_win32_gdkrectangle_to_string (&new_position)));
-      if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                         new_position.x, new_position.y, 
-                         new_position.width, new_position.height,
-                         SWP_NOACTIVATE | SWP_NOZORDER))
-        WIN32_API_FAILED ("SetWindowPos");
-        
-      tmp_list = obj->children;
-      while (tmp_list)
+      if (!ScrollWindowEx (GDK_WINDOW_HWND (window),
+                          -d_xoffset, -d_yoffset, /* in: scroll offsets */
+                          NULL, /* in: scroll rect, NULL == entire client area */
+                          NULL, /* in: restrict to */
+                          NULL, /* in: update region */
+                          NULL, /* out: update rect */
+                          SW_SCROLLCHILDREN))
+       WIN32_API_FAILED ("ScrollWindowEx");
+
+      if (dx != d_xoffset || dy != d_yoffset || is_resize)
        {
-         gdk_window_premove (tmp_list->data, &parent_pos);
-         tmp_list = tmp_list->next;
+         GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%dx%d@+%d+%d)\n",
+                                  GDK_WINDOW_HWND (window),
+                                  new_info.width, new_info.height,
+                                  new_info.x, new_info.y));
+         if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
+                            new_info.x, new_info.y, 
+                            new_info.width, new_info.height,
+                            SWP_NOACTIVATE | SWP_NOZORDER | 
+                            (is_move ? 0 : SWP_NOMOVE) |
+                            (is_resize ? 0 : SWP_NOSIZE)))
+           WIN32_API_FAILED ("SetWindowPos");
        }
 
-      GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,0x0@+%d+%d)\n",
-                              GDK_WINDOW_HWND (window),
-                              new_position.x + dx, new_position.y + dy));
-      if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                         new_position.x + dx, new_position.y + dy, 0, 0,
-                         SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOREDRAW))
-        WIN32_API_FAILED ("SetWindowPos");
-      
-      if (d_xoffset > 0 || d_yoffset > 0)
-       gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
-      
-      GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%dx%d@+%d+%d)\n",
-                              GDK_WINDOW_HWND (window),
-                              new_info.width, new_info.height,
-                              new_info.x, new_info.y));
-      if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                         new_info.x, new_info.y, 
-                         new_info.width, new_info.height,
-                         SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW))
-        WIN32_API_FAILED ("SetWindowPos");
-      
       if (impl->position_info.no_bg)
        gdk_window_tmp_reset_bg (window);
 
@@ -515,21 +275,18 @@ _gdk_window_move_resize_child (GdkWindow *window,
                                   GDK_WINDOW_HWND (window)));
          ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
        }
-      
+
       impl->position_info = new_info;
       
       tmp_list = obj->children;
       while (tmp_list)
        {
-         gdk_window_postmove (tmp_list->data, &parent_pos);
+         gdk_window_postmove (tmp_list->data, &parent_pos, FALSE);
          tmp_list = tmp_list->next;
        }
     }
   else
     {
-      if (is_move && is_resize)
-       gdk_window_set_static_gravities (window, FALSE);
-
       if (impl->position_info.mapped && !new_info.mapped)
        {
          GDK_NOTE (MISC, g_print ("...ShowWindow(%p, SW_HIDE)\n",
@@ -537,13 +294,6 @@ _gdk_window_move_resize_child (GdkWindow *window,
          ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
        }
       
-      tmp_list = obj->children;
-      while (tmp_list)
-       {
-         gdk_window_premove (tmp_list->data, &parent_pos);
-         tmp_list = tmp_list->next;
-       }
-
       GDK_NOTE (MISC, g_print ("...SetWindowPos(%p,%dx%d@+%d+%d)\n",
                               GDK_WINDOW_HWND (window),
                               new_info.width, new_info.height,
@@ -559,7 +309,7 @@ _gdk_window_move_resize_child (GdkWindow *window,
       tmp_list = obj->children;
       while (tmp_list)
        {
-         gdk_window_postmove (tmp_list->data, &parent_pos);
+         gdk_window_postmove (tmp_list->data, &parent_pos, FALSE);
          tmp_list = tmp_list->next;
        }
 
@@ -575,6 +325,8 @@ _gdk_window_move_resize_child (GdkWindow *window,
 
       impl->position_info = new_info;
     }
+  if (new_clip_region)
+    gdk_window_post_scroll (window, new_clip_region);
 }
 
 static void
@@ -736,8 +488,9 @@ gdk_window_compute_parent_pos (GdkWindowImplWin32 *window,
 }
 
 static void
-gdk_window_premove (GdkWindow          *window,
-                   GdkWindowParentPos *parent_pos)
+gdk_window_postmove (GdkWindow          *window,
+                    GdkWindowParentPos *parent_pos,
+                    gboolean            anti_scroll)
 {
   GdkWindowImplWin32 *impl;
   GdkWindowObject *obj;
@@ -745,13 +498,15 @@ gdk_window_premove (GdkWindow          *window,
   GList *tmp_list;
   gint d_xoffset, d_yoffset;
   GdkWindowParentPos this_pos;
+  GdkRegion *new_clip_region;
 
   obj = (GdkWindowObject *) window;
   impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
   
   gdk_window_compute_position (impl, parent_pos, &new_info);
 
-  gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
+  new_clip_region =
+    gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);
 
   this_pos.x = parent_pos->x + obj->x;
   this_pos.y = parent_pos->y + obj->y;
@@ -765,67 +520,8 @@ gdk_window_premove (GdkWindow          *window,
   d_xoffset = new_info.x_offset - impl->position_info.x_offset;
   d_yoffset = new_info.y_offset - impl->position_info.y_offset;
   
-  if (d_xoffset != 0 || d_yoffset != 0)
-    {
-      GdkRectangle new_position;
-
-      if (d_xoffset < 0 || d_yoffset < 0)
-       gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0));
-
-      compute_intermediate_position (&impl->position_info, &new_info, d_xoffset, d_yoffset,
-                                    &new_position);
-
-      GDK_NOTE (MISC, g_print ("gdk_window_premove: %s@+%d+%d\n"
-                              "...SetWindowPos(%s)\n",
-                              _gdk_win32_drawable_description (window),
-                              obj->x, obj->y,
-                              _gdk_win32_gdkrectangle_to_string (&new_position)));
-
-      if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
-                         new_position.x, new_position.y, 
-                         new_position.width, new_position.height,
-                      SWP_NOREDRAW | SWP_NOZORDER | SWP_NOACTIVATE))
-        WIN32_API_FAILED ("SetWindowPos");
-    }
-
-  tmp_list = obj->children;
-  while (tmp_list)
+  if (anti_scroll || (anti_scroll = d_xoffset != 0 || d_yoffset != 0))
     {
-      gdk_window_premove (tmp_list->data, &this_pos);
-      tmp_list = tmp_list->next;
-    }
-}
-
-static void
-gdk_window_postmove (GdkWindow          *window,
-                    GdkWindowParentPos *parent_pos)
-{
-  GdkWindowImplWin32 *impl;
-  GdkWindowObject *obj;
-  GdkWin32PositionInfo new_info;
-  GList *tmp_list;
-  gint d_xoffset, d_yoffset;
-  GdkWindowParentPos this_pos;
-
-  obj = (GdkWindowObject *) window;
-  impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
-  
-  gdk_window_compute_position (impl, parent_pos, &new_info);
-
-  this_pos.x = parent_pos->x + obj->x;
-  this_pos.y = parent_pos->y + obj->y;
-  this_pos.win32_x = parent_pos->win32_x + new_info.x;
-  this_pos.win32_y = parent_pos->win32_y + new_info.y;
-  this_pos.clip_rect = new_info.clip_rect;
-
-  d_xoffset = new_info.x_offset - impl->position_info.x_offset;
-  d_yoffset = new_info.y_offset - impl->position_info.y_offset;
-  
-  if (d_xoffset != 0 || d_yoffset != 0)
-    {
-      if (d_xoffset > 0 || d_yoffset > 0)
-       gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0));
-       
       GDK_NOTE (MISC, g_print ("gdk_window_postmove: %s@+%d+%d\n"
                               "...SetWindowPos(%dx%d@+%d+%d)\n",
                               _gdk_win32_drawable_description (window),
@@ -835,8 +531,8 @@ gdk_window_postmove (GdkWindow          *window,
 
       if (!SetWindowPos (GDK_WINDOW_HWND (window), NULL,
                          new_info.x, new_info.y, 
-                         new_info.width, new_info.height,
-                         SWP_NOREDRAW | SWP_NOZORDER | SWP_NOACTIVATE))
+                         0, 0,
+                         SWP_NOREDRAW | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE))
         WIN32_API_FAILED ("SetWindowPos");
     }
 
@@ -848,64 +544,17 @@ gdk_window_postmove (GdkWindow          *window,
 
   impl->position_info = new_info;
 
+  if (new_clip_region)
+    gdk_window_post_scroll (window, new_clip_region);
+
   tmp_list = obj->children;
   while (tmp_list)
     {
-      gdk_window_postmove (tmp_list->data, &this_pos);
+      gdk_window_postmove (tmp_list->data, &this_pos, anti_scroll);
       tmp_list = tmp_list->next;
     }
 }
 
-#if 0
-
-static void
-gdk_window_queue_append (GdkWindow          *window,
-                        GdkWindowQueueItem *item)
-{
-  if (g_slist_length (translate_queue) >= 128)
-    {
-      GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
-
-      GDK_NOTE (EVENTS, g_print ("gdk_window_queue_append: length >= 128\n"));
-      _gdk_window_process_expose (window, _gdk_win32_get_next_tick (0),
-                                 &impl->position_info.clip_rect);
-    }
-
-  item->window = window;
-  item->serial = GetTickCount ();
-
-  GDK_NOTE (EVENTS, (g_print ("gdk_window_queue_append: %s %p %ld ",
-                             (item->type == GDK_WINDOW_QUEUE_TRANSLATE ?
-                              "TRANSLATE" : "ANTIEXPOSE"),
-                             GDK_WINDOW_HWND (window),
-                             item->serial),
-                    (item->type == GDK_WINDOW_QUEUE_TRANSLATE ?
-                     g_print ("%d,%d\n",
-                              item->u.translate.dx, item->u.translate.dy) :
-                     g_print ("%s\n",
-                              _gdk_win32_gdkregion_to_string (item->u.antiexpose.area)))));
-
-  g_object_ref (window);
-  translate_queue = g_slist_append (translate_queue, item) ;
-}
-
-#endif
-
-static void
-gdk_window_queue_translation (GdkWindow *window,
-                             gint       dx,
-                             gint       dy)
-{
-#if 0
-  GdkWindowQueueItem *item = g_new (GdkWindowQueueItem, 1);
-  item->type = GDK_WINDOW_QUEUE_TRANSLATE;
-  item->u.translate.dx = dx;
-  item->u.translate.dy = dy;
-
-  gdk_window_queue_append (window, item);
-#endif
-}
-
 gboolean
 _gdk_windowing_window_queue_antiexpose (GdkWindow *window,
                                        GdkRegion *area)
@@ -929,65 +578,11 @@ _gdk_window_process_expose (GdkWindow *window,
 {
   GdkWindowImplWin32 *impl;
   GdkRegion *clip_region;
-#if 0
-  GSList *tmp_list = translate_queue;
-#endif
   impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
   
   GDK_NOTE (EVENTS, g_print ("_gdk_window_process_expose: %p %s\n",
                             GDK_WINDOW_HWND (window),
                             _gdk_win32_gdkregion_to_string (invalidate_region)));
-#if 0
-  while (tmp_list)
-    {
-      GdkWindowQueueItem *item = tmp_list->data;
-      tmp_list = tmp_list->next;
-
-      if (serial < item->serial)
-       {
-         if (item->window == window)
-           {
-             if (item->type == GDK_WINDOW_QUEUE_TRANSLATE)
-               {
-                 GDK_NOTE (EVENTS, g_print ("...item %ld xlating region by %d,%d\n",
-                                            item->serial,
-                                            item->u.translate.dx, item->u.translate.dy));
-                 gdk_region_offset (invalidate_region, - item->u.translate.dx, - item->u.translate.dy);
-               }
-             else              /* anti-expose */
-               {
-#ifdef G_ENABLE_DEBUG
-                 GdkRectangle rect;
-
-                 GDK_NOTE (EVENTS,
-                           (gdk_region_get_clipbox (item->u.antiexpose.area, &rect),
-                            g_print ("...item %ld antiexposing %s\n",
-                                     item->serial,
-                                     _gdk_win32_gdkrectangle_to_string (&rect))));
-#endif
-                 gdk_region_subtract (invalidate_region, item->u.antiexpose.area);
-               }
-           }
-       }
-      else
-       {
-         GSList *tmp_link = translate_queue;
-         
-         GDK_NOTE (EVENTS, g_print ("...item %ld being removed\n", item->serial));
-
-         translate_queue = g_slist_remove_link (translate_queue, translate_queue);
-         g_object_unref (item->window);
-
-         if (item->type == GDK_WINDOW_QUEUE_ANTIEXPOSE)
-           gdk_region_destroy (item->u.antiexpose.area);
-         
-         g_free (item);
-         g_slist_free_1 (tmp_link);
-       }
-    }
-
-  GDK_NOTE (EVENTS, g_print ("...queue length now %d\n", g_slist_length (translate_queue)));
-#endif
   clip_region = gdk_region_rectangle (&impl->position_info.clip_rect);
   gdk_region_intersect (invalidate_region, clip_region);
 
@@ -1026,21 +621,9 @@ gdk_window_tmp_reset_bg (GdkWindow *window)
   impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
 
   impl->position_info.no_bg = FALSE;
-
-  if (obj->bg_pixmap == GDK_NO_BG)
-    return;
-  
-  if (obj->bg_pixmap)
-    {
-      /* ??? */
-    }
-  else
-    {
-      /* ??? */
-    }
 }
 
-static void
+static GdkRegion *
 gdk_window_clip_changed (GdkWindow    *window,
                         GdkRectangle *old_clip,
                         GdkRectangle *new_clip)
@@ -1051,7 +634,7 @@ gdk_window_clip_changed (GdkWindow    *window,
   GdkRegion *new_clip_region;
   
   if (((GdkWindowObject *)window)->input_only)
-    return;
+    return NULL;
 
   obj = (GdkWindowObject *) window;
   impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
@@ -1059,11 +642,6 @@ gdk_window_clip_changed (GdkWindow    *window,
   old_clip_region = gdk_region_rectangle (old_clip);
   new_clip_region = gdk_region_rectangle (new_clip);
 
-  /* We need to update this here because gdk_window_invalidate_region makes
-   * use if it (through gdk_drawable_get_visible_region
-   */
-  impl->position_info.clip_rect = *new_clip;
-  
   /* Trim invalid region of window to new clip rectangle
    */
   if (obj->update_area)
@@ -1073,14 +651,25 @@ gdk_window_clip_changed (GdkWindow    *window,
    */
   gdk_region_subtract (new_clip_region, old_clip_region);
   if (!gdk_region_empty (new_clip_region))
+    gdk_window_tmp_unset_bg (window);
+  else
     {
-      gdk_window_tmp_unset_bg (window);
-      GDK_NOTE (EVENTS,
-               g_print ("gdk_window_clip_changed: invalidating region: %s\n",
-                        _gdk_win32_gdkregion_to_string (new_clip_region)));
-      gdk_window_invalidate_region (window, new_clip_region, FALSE);
+      gdk_region_destroy (new_clip_region);
+      new_clip_region = NULL;
     }
+  gdk_region_destroy (old_clip_region);
+
+  return new_clip_region;
+}
 
+static void
+gdk_window_post_scroll (GdkWindow    *window,
+                       GdkRegion    *new_clip_region)
+{
+  GDK_NOTE (EVENTS,
+           g_print ("gdk_window_clip_changed: invalidating region: %s\n",
+                    _gdk_win32_gdkregion_to_string (new_clip_region)));
+
+  gdk_window_invalidate_region (window, new_clip_region, FALSE);
   gdk_region_destroy (new_clip_region);
-  gdk_region_destroy (old_clip_region);
 }
index bc3f69d506faba25999536817841f0218fd55bdc..b68f93519a8bf56034f28e880cdddfc5324a9283 100644 (file)
@@ -288,8 +288,8 @@ gdk_window_impl_win32_get_visible_region (GdkDrawable *drawable)
         {
           GdkRectangle gr;
 
-          gr.x = r.left;
-          gr.y = r.top;
+          gr.x = r.left + impl->position_info.x_offset;
+          gr.y = r.top + impl->position_info.y_offset;
           gr.width = r.right - r.left;
           gr.height = r.bottom - r.top;
 
@@ -661,9 +661,6 @@ gdk_window_new_internal (GdkWindow     *parent,
       window_height = impl->position_info.height;
     }
 
-  if (impl->position_info.big)
-    private->guffaw_gravity = TRUE;
-
   if (attributes_mask & GDK_WA_TITLE)
     title = attributes->title;
   else
@@ -673,11 +670,6 @@ gdk_window_new_internal (GdkWindow     *parent,
 
   private->event_mask = GDK_STRUCTURE_MASK | attributes->event_mask;
       
-  if (private->parent && private->parent->guffaw_gravity)
-    {
-      /* XXX ??? */
-    }
-
   if (private->parent)
     private->parent->children = g_list_prepend (private->parent->children, window);
 
@@ -1347,13 +1339,6 @@ gdk_window_reparent (GdkWindow *window,
     old_parent_private->children =
       g_list_remove (old_parent_private->children, window);
 
-#if 0
-  if ((old_parent_private &&
-       (!old_parent_private->guffaw_gravity != !parent_private->guffaw_gravity)) ||
-      (!old_parent_private && parent_private->guffaw_gravity))
-    gdk_window_set_static_win_gravity (window, parent_private->guffaw_gravity);
-#endif
-
   parent_private->children = g_list_prepend (parent_private->children, window);
   _gdk_window_init_position (GDK_WINDOW (window_private));
 }
@@ -2853,15 +2838,7 @@ gdk_window_set_static_gravities (GdkWindow *window,
   g_return_val_if_fail (window != NULL, FALSE);
   g_return_val_if_fail (GDK_IS_WINDOW (window), FALSE);
 
-  if (!use_static == !private->guffaw_gravity)
-    return TRUE;
-  
-  if (use_static)
-    return FALSE;
-  
-  private->guffaw_gravity = use_static;
-  
-  return TRUE;
+  return !use_static;
 }
 
 void